package com.woniuxy.classteacher.mqreceiver;

import com.rabbitmq.client.Channel;
import com.woniuxy.classteacher.uitility.SendMessage;
import com.woniuxy.commons.entity.StudentInfo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Auther: 牟强
 * @Date: 2020/7/18/018 14:36
 * @Description:
 */
@Component
public class PhoneMQ {
    @RabbitListener(queues = "phone")
    public void received(StudentInfo student, Channel channel, Message message) throws IOException {
        System.out.println("手机短信收到" + student);
        SendMessage.sendSms(student.getPhone(),"1");
        //手动确认消息
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
